<?php 

$response = array();

require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();

mysql_query("set names 'utf8'");

$result = mysql_query("SELECT * FROM LOAI_MON_AN") or die(mysql_error());

if(mysql_num_rows($result)){
	$response["type_foods"] = array();
	while ($row = mysql_fetch_array($result)){
		$type = array();
		$type["id"] = $row["id"];
		$type["TEN_LOAI_MON_AN"] = $row["TEN_LOAI_MON_AN"];
		
		array_push($response["type_foods"], $type);
	}
	// success
	$response["success"] = 1;
	// echoing JSON response
	echo utf8_encode(json_encode($response));
} else {
	// no products found
	$response["success"] = 0;
	$response["message"] = "No foods found";

	// echo no users JSON
	print utf8_encode(json_encode($response));
}

?>